class BaseResponse {
  //访问成功 == 0
  int errorCode;

  //访问失败时候，的描述信息
  String errorMsg;

  // 透传网络数据
  var data;

  BaseResponse(this.errorCode, {this.errorMsg, this.data});

  BaseResponse.fromJson(Map<String, dynamic> json) {
    data = json["data"];
    errorCode = json["errorCode"];
    errorMsg = json["errorMsg"];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data["data"] = this.data;
    data["errorCode"] = this.errorCode;
    data["errorMsg"] = this.errorMsg;
    return data;
  }

  /// 请求成功
  bool success() => errorCode == 0;

  bool hasData() => success() && data != null;

  @override
  String toString() {
    return 'BaseResponse{errorCode: $errorCode, errorMsg: $errorMsg, data: $data}';
  }
}
